#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>

int main()
{
    pid_t ret = fork();
    if(ret < 0)
    {
        perror("fork!");
        return 1;
    }
    else if(ret == 0)
    {
        //子进程
        while(1)
        {
            printf("我是子进程：Pid:%d PPid:%d\n",getpid(),getppid());
            sleep(1);
        }
    }
    else 
    {
        //父进程
        while(1)
        {
            printf("我是父进程：Pid:%d PPid:%d\n",getpid(),getppid());
            sleep(1);
        }
    }
    return 0;
}
